package com.videconferencia.eao;

import java.util.List;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import com.videconference.entity.MdlVideoconferenciacfg;

/**
 * Session Bean implementation class ConfigurationEAO
 */
@Stateless(mappedName = "configurationEAO")
public class ConfigurationEAO implements ConfigurationEAOLocal {

	@PersistenceContext(unitName="VideoConferenceEAREJB")
    EntityManager entityManager;
	
    /**
     * Default constructor. 
     */
    public ConfigurationEAO() {
        // TODO Auto-generated constructor stub
    }

	@Override
	public void saveConfiguration(String host, String port) {
		MdlVideoconferenciacfg config = new MdlVideoconferenciacfg();
		config.setHost(host);
		config.setPort(Integer.valueOf(port));
		entityManager.persist(config);
	}

	@Override
	public List<MdlVideoconferenciacfg> getAllRecords() {
		//return entityManager.createNamedQuery("MdlVideoconferenciacfg.findAll").getResultList();
		return entityManager.createQuery("SELECT c FROM MdlVideoconferenciacfg c").getResultList();
	}


}
